home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Marlais / MacMarlais 0.5.9d46 / external primitive / Source / external_primitive.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-09  |  2.5 KB  |  70 lines  |  [TEXT/KAHL]

  1. /*
  2.     external_primitive.h
  3.     
  4.     definitions for writing external primitives for Marlais.
  5.     
  6.     by Patrick C. Beard.
  7.     
  8.     68K version.
  9.  */
  10.  
  11. #ifndef __EXTERNAL_PRIMITIVE__
  12. #define __EXTERNAL_PRIMITIVE__
  13.  
  14. #include <stddef.h>
  15. #include "object.h"
  16.  
  17. // a set of procedures to support the use of external primitives.
  18.  
  19. struct ExternalPrimitiveCallbacks {
  20.     // access to primitive function loader.
  21.     void (*init_prims) (int num, struct primitive prims[]);
  22.     
  23.     // Environment routines.
  24.     Object (*eval) (Object obj);                                // evaluate an object.
  25.     Object (*apply) (Object func, Object args);                    // apply a function to arguments.
  26.     Object (*symbol_value) (Object sym);                        // look up a global symbol's value.
  27.     void (*modify_value) (Object sym, Object new_val);            // change a global symbol's value.
  28.     
  29.     // Error routines.
  30.     Object (*error) (char* message, ...);                        // signals a runtime error. terminate args with NULL.
  31.     Object (*warning) (char *msg, ...);                            // prints out a "warning: %s" message.
  32.     
  33.     // Object allocation primitives.
  34.     Object (*make_foreign_ptr) (void* ptr);                        // make a <foreign-pointer>.
  35.     Object (*make_byte_string) (char* str);                        // make a <string>.
  36.     Object (*make_symbol) (char* symstr);                        // make a <symbol>.
  37.     Object (*make_keyword) (char* keystr);                        // make a <keyword>.
  38.     Object (*cons) (Object car, Object cdr);                    // make a <pair>.
  39.     Object (*listem) (Object car, ...);                            // make a <list>. terminate args with NULL.
  40.  
  41.     // low-level access to the garbage collector.
  42.     void* (*GC_malloc) (size_t size_in_bytes);                    // shouldn't be necessary.
  43.     void* (*GC_malloc_atomic) (size_t size_in_bytes);
  44.     void (*GC_free) (void* object_addr);
  45.     void (*GC_add_roots) (void * low_address, void * high_address_plus_1);
  46. };
  47.  
  48. typedef struct ExternalPrimitiveCallbacks ExternalPrimitiveCallbacks;
  49.  
  50. struct ExternalPrimitiveObjects {
  51.     Object unspecified_object, false_object, true_object;        // common return values.
  52. };
  53.  
  54. typedef struct ExternalPrimitiveObjects ExternalPrimitiveObjects;
  55.  
  56. #define cExternalPrimitiveSupportVersion 0x0100
  57.  
  58. struct ExternalPrimitiveSupport {
  59.     short version;                                // version number of support structure.
  60.     ExternalPrimitiveCallbacks* callbacks;        // pointer to callbacks structure.
  61.     ExternalPrimitiveObjects* objects;            // pointer to objects structure.
  62.     // other objects can be accessed by symbol_value callback.
  63. };
  64.  
  65. typedef struct ExternalPrimitiveSupport ExternalPrimitiveSupport;
  66.  
  67. typedef void (*ExternalPrimitiveLoader) (ExternalPrimitiveSupport* support);
  68.  
  69. #endif /* __EXTERNAL_PRIMITIVE__ */
  70.